﻿using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;

namespace MichMan.Utilities.UnitTest
{
    [TestClass]
    public class EnumUtilityTests
    {
        [TestMethod]
        public void FlagsTest()
        {
            FileAccess fa = FileAccess.Read | FileAccess.Write;
            Assert.IsTrue(fa.TestFlag(FileAccess.Read));
            Assert.IsTrue(fa.TestFlag(FileAccess.Write));
            Assert.IsFalse(FileAccess.Read.TestFlag(FileAccess.Write));

            Assert.IsTrue(EnumUtility.TryParse<FileAccess>(fa.ToString(), out fa));
            Assert.IsTrue(fa.TestFlag(FileAccess.Read));
            Assert.IsTrue(fa.TestFlag(FileAccess.Write));

            Assert.IsTrue(EnumUtility.TryParse<FileAccess>("Read", out fa));
            Assert.IsTrue(fa.TestFlag(FileAccess.Read));
            Assert.IsFalse(fa.TestFlag(FileAccess.Write));

            Assert.IsTrue(EnumUtility.TryParse<FileAccess>("2", out fa));
            Assert.IsFalse(fa.TestFlag(FileAccess.Read));
            Assert.IsTrue(fa.TestFlag(FileAccess.Write));

            Assert.AreEqual(EnumUtility.GetNames<FileAccess>().Count(), 3);
            Assert.AreEqual(EnumUtility.GetValues<FileAccess>().Count(), 3);
        }
    }
}
